const fs = require('fs')

var fn_hello = async (ctx, next) => {
    let data = findSync()
    // ctx.body = data
    // ctx.body.status = 200
    // ctx.body.type = 'application/xml'
    // ctx.body = data
    ctx.body = {
        success: true,
        data: data
      }
};
function findSync() {
    let result=[];
    const files = fs.readdirSync('./static')
    files.forEach(function (item, index) {
        let stat = fs.lstatSync("./static/" + item)
        if (stat.isDirectory() === true) { 
            result.push(item)
        }else{
            result.push(item)
        }
    });
    return result;
}

module.exports = {
    'GET /api/list': fn_hello
};
